package org.example.code.test2025.two_month;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class test0213 {
    public static void main(String [] args)

    {
        test0213 ye = new test0213();
        int[] a = {1,1,2,2,3};
        System.out.println(ye.duduplicate(a).toString());

    }


    public int[] duduplicate(int[] array){
        Set<Integer> set = new HashSet<>();
        int[] re = new int[array.length];
        int index = 0;
        for(Integer a: array){
            if (set.add(a)) {
                re[index]= a;
                index++;
            }
        }
        return Arrays.copyOf(re,index);
    }
}
